<?php


namespace App\Logging;


use Illuminate\Log\Logger;
use Monolog\Formatter\LineFormatter;

class AppLogFormatter
{
    /**
     * Customize the given logger instance.
     *
     * @param Logger $logger
     * @return void
     */
    public function __invoke(Logger $logger)
    {
        $app = app();
        $dataFormat = 'Y-m-d H:i:s';
        $format = "[%datetime%] %channel%.%level_name%: {$app->request->decodedPath()} [" . $_SERVER['REQUEST_TIME'] . "] %message% %context% %extra%\n";
        foreach ($logger->getHandlers() as $handler) {
            $handler->setFormatter(new LineFormatter($format , $dataFormat, true, true));
        }
    }
}
